<?php

class YWSEditor {

    public static $_ImagePath;
    public static $_FlashPath;
    public static $_DocumentPath;

    public static function FCKPath() {
        $basePath = Yii::app()->baseUrl . '/fckeditor/' ;
        return $basePath;
    }

    public static function renderFCKEditor($text = null, $id = 'fckeditor', $width = '700', $height='450', $model = null, $attribute = null, $options = array()) {
//        include_once '/fckeditor/fckeditor.php';
        if (is_null($model) && is_null($attribute))
            $FCKeditor = new FCKeditor('fckeditor1');
        else{
            $FCKeditor = new FCKeditor(get_class($model).'['.$attribute.']');
            $FCKeditor->editor(get_class($model).'['.$attribute.']',$text);
        }
        $FCKeditor->BasePath = YWSEditor::FCKPath();
        $FCKeditor->Value = $text;
        $FCKeditor->Width = $width;
        $FCKeditor->Height = $height;
        $FCKeditor->InstanceName = $id;

        //assign op
        if (isset($options) && is_array($options)) {
            foreach ($options as $key => $value) {
                $FCKeditor->Config[$key] = $value;
            }
        }
        $FCKeditor->Config['EnterMode'] = 'br';
        $FCKeditor->Create();
    }

}

?>
